import { Component, OnInit,Input } from '@angular/core';
import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
import { NzModalRef, NzModalService } from 'ng-zorro-antd';
import { UtilService } from '../my-service/util.service';
import { appService } from '../my-service/app.service';
@Component({
  selector: 'nav-root',
  templateUrl: './nav.component.html',
  styleUrls: ['./nav.component.css'],
  
})
export class NavComponent implements OnInit {
  // FK_CanvasGuid="2c978a81-4807-68bc-27c3-1bf6ced74ff5"
  // unlogin = true;
  @Input() activeMenu: string;
  Message=false; 
  msgload=false;
 
  unlogin: boolean = false;
  userGuid;
  // userGuid: string = 'c9ea1029-8f0f-368f-39c5-505297e2b59e';
  usermsg: any = [];
  menuList = [
     { name: '开始', address: 'home' },
     { name: '其他应用', address: 'other' },
   ];
  constructor(
    private router: Router,
    private activatedRoute: ActivatedRoute,
    private modal: NzModalService,
    private appservice: appService,
    private utilService: UtilService
  ) { }

  ngOnInit() {
    this.GetUserMsg();
  }
  
  goHome() {
    this.router.navigate(['/']);
  }
  goto(index){
    if(index==0){
      this.goHome()
    }else{
      this.router.navigate(['/other']);
    }
  }
   //获取用户信息
   GetUserMsg() {
    this.utilService.getUserInfo().then(re0 => {
      if (re0.status == 1) {
        this.unlogin = false;
        this.userGuid = re0.userGuid;
        this.utilService.GetStudentUser(this.userGuid).then(re => {
          this.usermsg = re.data;
        })
      }
      else this.unlogin = true
    })
  }
  // 测试/示例方法，可删除
  getUserInfoTest() {
    this.utilService.getUserInfo().then(res => {
    });
  }
    //登出
    logout() {
      this.utilService.comfirm('确认退出登录？', () => {
        this.utilService.logout().then(res => {
          if (res.status === 1) {
            this.utilService.remind('success', '退出成功!');
            window.location.reload();
          }
          else this.utilService.remind('warning', '退出失败，请重试！');
        });
      });
    }
    //跳转
    link(path) {
      location.href = path
    }
    link2(){

    }
}